//
// UDevFS.h
// Usage: udev filesystem
// CreateDate: 2009-05-09
// Author: MaJiuyue
//
#ifndef _UDEVFS_H_
#define _UDEVFS_H_

#include <Map.h>
#include "FileSystem.h"
#include "File.h"
#include "Directory.h"
#include "DeviceFile.h"

class UDevFS : public FileSystem
{
private:
	/* major<->pid */
	Map<u16, pid_t, 64> m_DeviceMap;

public:
	UDevFS();
	~UDevFS();

public:
	/*
	   Make a device file with name of 'name', driver process's pid 'pid',
	   major number 'major', total create 'cnt' files
	*/
	File * CreateDevice(const char *name, pid_t pid, u16 major, u16 cnt);

public:
	virtual int read(u32 inode, off_t off, size_t size, addr_t buf);
	virtual int write(u32 inode, off_t off, size_t size, addr_t buf);
	virtual File * TraversalPath(Directory *target, const char *path);
};

#endif

